﻿using UnityEngine;
using System.Collections;

public class machineGun : MonoBehaviour {
	
	private float time = 0.5f;
	private float moment = -0.5f;
	private bool shot = false;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void FixedUpdate () {

		if(Input.GetButton("Fire1") && !shot && Time.timeSinceLevelLoad-moment > time){
			GameObject bala;
			string String = "AmmoPlayer";
			bala = Instantiate(Resources.Load ("Prefabs/Bala")) as GameObject;
			(bala.GetComponent("Ammo") as Ammo).setOnPlayer(gameObject, new Vector3(0,1,0));
			(bala.GetComponent("Ammo") as Ammo).setLayer(String);
			shot = true;
			moment = Time.timeSinceLevelLoad;
		}
		else if(!Input.GetButton("Fire1")){
			shot = false;
		}
	}
}
